// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import BaseUI from "../framwork/BaseUI";
import qxc_tools from "../framwork/qxcTools/qxc_tools";
import landGridItem from "./landGridItem";
import newLandItem from "./newLandItem";

const {ccclass, property} = cc._decorator;

@ccclass
export default class Game extends BaseUI {

    private static _instance: Game = null;
    public static getInstance(): Game {
        return Game._instance;
    }
    baseUI_onLoad(): void {
        Game._instance = this;
        this.createNewData();
        this.createNewLand();


    }
    data:any = {
        lands:[],
    };
    createNewData(){
        let str = [
            "城堡","攻击","防御","暴击","暴伤","血量",
        ]
        this.data.lands = [];
        for (let i = 0; i < 3; i++) {
            let land = [];
            for (let j = 0; j < 2; j++) {
                let ranNum = qxc_tools.ranNumber(1,6);
                let huanguan = 0;
                let ranNum2 = qxc_tools.ranNumber(0,100);
                if(ranNum2 < 10){
                    huanguan = 3
                } else if (ranNum2 < 25){
                    huanguan = 2
                } else if (ranNum2 < 45){
                    huanguan = 1
                }
                let data = {
                    id:ranNum,
                    name:str[ranNum],
                    huanguan:huanguan
                }
                land.push(data)
            }
            this.data.lands.push(land);
        }
    }
    newLands:cc.Node;
    newLandItem:cc.Node;
    createNewLand(){
        console.log(this.data);
        qxc_tools.createItemList(this,this.data.lands,newLandItem.name);
    }
    baseUI_onDestroy(): void {
        
    }
    onBtn_click(target: cc.Button, onBtn_name: string): number | void {

    }
    init_data(d: any): void {

    }

}
